package com.example.gymlearning.service.impl;

import com.example.gymlearning.entity.LearningTask;
import com.example.gymlearning.mapper.LearningTaskMapper;
import com.example.gymlearning.service.LearningTaskService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (LearningTask)表服务实现类
 *
 * @author makejava
 * @since 2025-10-27 14:38:04
 */
@Service("learningTaskService")
public class LearningTaskServiceImpl implements LearningTaskService {
    @Resource
    private LearningTaskMapper learningTaskMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LearningTask queryById(Long id) {
        return this.learningTaskMapper.queryById(id);
    }

      /**
     * 新增数据
     *
     * @param learningTask 实例对象
     * @return 实例对象
     */
    @Override
    public LearningTask insert(LearningTask learningTask) {
        this.learningTaskMapper.insert(learningTask);
        return learningTask;
    }

    /**
     * 修改数据
     *
     * @param learningTask 实例对象
     * @return 实例对象
     */
    @Override
    public LearningTask update(LearningTask learningTask) {
        this.learningTaskMapper.update(learningTask);
        return this.queryById(learningTask.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.learningTaskMapper.deleteById(id) > 0;
    }
}
